;(async function(){
    const express = require("express")
    const cors = require("cors")

    const db = require("./db/db")
    const router = require("./routes/route")

    try{
        await db
        console.log("数据库连接成功")
        const app = express()

        app.use(express.json())
        app.use(cors())

        app.use(router)

        app.listen(5000,(err)=>{
            if(err) console.log('fail')
            else console.log("ok")
        })
    }catch(err){
        console.log("数据库连接失败")
    }
})()
